import Vue from 'vue'
import VueRouter from 'vue-router'
import recommend from '../views/recommend.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: '/recommend',
  },
  {
    path: "/userInfo",
    name: "userInfo",
    component: () => import("../views/userinfo.vue"),
    beforeEnter: (to, from, next) => {
      let Signin = window.localStorage.getItem("token");
      // 判断没有值
      if (!Signin) {
        next("/Signin");
        return;
      } else {
        next();
      }
    }
  },
  {
    path: "/Signin",
    name: "Signin",
    meta: {
      footerNav: true
    },
    component: () => import("../components/base/Signin.vue")
  },
  {
    path: '/recommend',
    name: 'recommend',
    component: recommend
  },
  {
    path: '/recommend/singerID',
    name: 'singerID',
    component: () => import('../components/rank/singerID.vue')

  },
  {
    path: '/ranking',
    name: 'ranking',
    component: () => import('../views/ranking.vue')
  },
  {
    path: '/podcast',
    name: 'podcast',
    component: () => import('../views/podcast.vue')
  },
  {
    path: '/ranking/rankinglist',
    name: 'rankinglist',
    component: () => import('../components/rank/rankinglist.vue')
  },
  {
    path: '/singer',
    name: 'singer',
    component: () => import('../views/singer.vue')
  },
  {
    path: '/userinfo/RecentlyPlayed',
    name: 'RecentlyPlayed',
    component: () => import('../components/rank/RecentlyPlayed.vue')
  },
  {
    path: '/userinfo/LocalDownload',
    name: 'LocalDownload',
    component: () => import('../components/base/LocalDownload.vue')
  },
  {
    path: '/userinfo/GoodFriend',
    name: 'GoodFriend',
    component: () => import('../components/rank/GoodFriend.vue')
  },
  {
    path: '/recommend/MoreSongs',
    name: 'MoreSongs',
    component: () => import('../components/rank/MoreSongs.vue')
  },
  {
    path: '/recommend/PopularSinger',
    name: 'PopularSinger',
    component: () => import('../components/rank/PopularSinger.vue')
  },
  {
    path: '/recommend/PopularMV',
    name: 'PopularMV',
    component: () => import('../components/rank/PopularMV.vue')
  },
  {
    path: '/Comments',
    name: 'Comments',
    component: () => import('../views/Comments.vue')
  },
  {
    path: '/PlayMV',
    name: 'PlayMV',
    component: () => import('../views/PlayMV.vue')
  },
  {
    path: '/recommend/setID',
    name: 'setID',
    component: () => import('../components/rank/setID.vue')
  },
  {
    path: '/recommend/RecommendSongs',
    name: 'RecommendSongs',
    component: () => import('../components/rank/RecommendSongs.vue')
  },
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router